/**
 * 
 */
package galaxy.drawer;

import galaxy.drawer.action.Action;
import galaxy.generator.AbstractNodeVisitor;
import galaxy.generator.Node;

import java.util.Map;

public class NodeActionExecutor extends AbstractNodeVisitor
{
	private Context context;
	private Map<String, Action> actions;
	
	public NodeActionExecutor(Context initial, Map<String, Action> actions)
	{
		this.context = initial;
		this.actions = actions;
	}
	
	public void enterNode(Node n) {
		context.node = n;
		if (actions.containsKey(n.getValue())) {
			this.context = actions.get(n.getValue()).execute(context);
		}
	}
}